What is an algorithm?
An algorithm is a set of instructions used to solve a problem. It is important that the instructions or steps are written in a logical order e.g. it is impossible to get to a mall before waking up!
Pseudocode is one way in which an algorithm may be written.
Pseudocode is steps in an algorithm written in plain language for ease of understanding.
An example of pseudocode to add two numbers and display the sum of the two numbers is as follows:
- Start
- Declare variables num1, num2 and sum
- Assign values to num1 and num2
- Add variables num1 and num2 and store the result in the variable sum
- Display the sum to the console
- End
To truly grasp the concept of pseudocode the following video can be watched:
Another way in which an algorithm can be presented is in the form of a flow chart.
A flow chart is a diagrammatic representation of an algorithm that consists of shapes joined using symbols to show the logic of the algorithm.
The following images show the shapes and symbols used in a flow chart:
Comments
Post a Comment